import { shallowMount } from '@vue/test-utils';
import LoginComponent from '@/components/LoginComponent.vue';
import axios from 'axios';
import api from '@/api';


jest.mock('axios');

describe('用户注册测试套件', () => {
  test('合法用户应成功注册', async () => {
    const res = await api.user.login({ username: 'validUser', password: 'P@ssw0rd' });
    expect(res.status).toBe(200);
    expect(res.data).toHaveProperty('token');
  });

  test('空用户名应返回错误码403', async () => {
    const res = await api.user.login({ username: '', password: 'P@ssw0rd' });
    expect(res.status).toBe(403);
    expect(res.data.message).toMatch(/用户名不能为空/);
  });
});
